<?php
error_reporting(0);
header('Content-type:text/json;charset=utf-8');     //这句是重点，它告诉接收数据的对象此页面输出的是json数据；
echo "&";
$name = $_GET['name'];

$name = filter($name);

if(empty($name)){
    die('{"status":"Need More Information"} ');
    echo "&";
}

$mysqli = new mysqli('localhost', 'GameServer', 'J8TED4Ks3CPkAdHY', 'gameserver');

if ($mysqli->connect_error) {
    die('{"status":"Connect Error (' . $mysqli->connect_errno . ')"}' . $mysqli->connect_error);
    echo "&";
}

$sql = "SELECT * FROM `data` WHERE `id` = '".$name."'";
$result = $mysqli->query($sql);
if (mysqli_num_rows($result) > 0) {
    // 输出数据
    while($row = mysqli_fetch_assoc($result)) {
        echo $row['id']." ".$row['totilKilled']." ".$row['maxOnceKilled']." ".$row['level']." ".$row['lastTime']." ".$row['updatetime'];
    }
} else {
    echo "No Result";
}
echo "&";
?>